package cn.edu.ctbu.datajpa01.aspect;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component//组件
@Aspect//切面
@Slf4j//生成log对象
public class HttpAspect {
//切入方法：StudentApiController中的全部方法
    @Pointcut("execution(* cn.edu.ctbu.datajpa01.api.StudentApiController.*(..))")

    public  void log(){

    }
    //切入方法之后1
    @Before("log()")
    public void doBefore(){
        System.out.println("准备开始执行list...");
    }
    //切入方法之后3
    @After("log()")
    public  void doAfter(){
        System.out.println("执行list完，准备返回...");
    }
    //切入方法之后2执行方法后返回
    @AfterReturning(returning = "object",pointcut = "log()")
    public  void AfterR(Object object){
        log.info("response={}",object);
    }
}//返回值是object
